package com.hxzy.commons.util;

import java.util.Calendar;

/**
 * <p>
 * 类描述：时间工具类
 * <p>
 * 创建人：Abdi
 * <p>
 * 创建时间：2013-10-13 下午09:42:06
 */
public class DateUtil {
	/**
	 * 获取当前时间 ：yyyyddmmH24MMss
	 * @return
	 */
	public static String currentDateTime(){
	    Calendar cal = Calendar.getInstance();
	    long val = cal.get(1) * 10000 + (cal.get(2) + 1) * 100 + cal.get(5);
	    long val1 = cal.get(11) * 10000 + cal.get(12) * 100 + cal.get(13);
	    String tmp = String.valueOf(val1);
	    String timeStr = new StringBuilder().append("000000".substring(tmp.length())).append(tmp).toString();
	    return new StringBuilder().append(String.valueOf(val)).append(timeStr).toString();
	}
	
	/**
	 * 获取当前时间: yyyymmdd
	 * @return
	 */
	public static String currentDate(){
	    Calendar cal = Calendar.getInstance();
	    long val = cal.get(1) * 10000 + (cal.get(2) + 1) * 100 + cal.get(5);
	    return String.valueOf(val);
	}
	
	/**
	 * 获取当前时间 ：H24MMss
	 * @return
	 */
	public static String currentTime(){
		Calendar cal = Calendar.getInstance();
		long val1 = cal.get(11) * 10000 + cal.get(12) * 100 + cal.get(13);
		String tmp = String.valueOf(val1);
		return new StringBuilder().append("000000".substring(tmp.length())).append(tmp).toString();
	}
	
	public static void main(String[] args) {
		System.out.println(currentDateTime());
		System.out.println(currentDate()+" " +new Long(currentDate()));
		System.out.println(currentTime());
	}
}
